/**
 * 
 */
package logic;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Restrictions;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

import model.BirthdayEntry;

/**
 * @author cellamaro
 *
 */
@ManagedBean(name="reminderBean")
@SessionScoped
public class Reminder {

	public List<BirthdayEntry> getAllBirthdays(){
		
		Configuration configuration=new Configuration();  
		configuration.configure();  
		ServiceRegistry sr= new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();  
		SessionFactory sf=configuration.buildSessionFactory(sr);
		
		Session session = sf.openSession();
		return (List<BirthdayEntry>) session.createCriteria(BirthdayEntry.class).list(); 
		
	}
}
